| Conditions | 5 |
| Paths | 12 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import optionsFromStrings from "./optionsFromStrings.js"; |
||
| 4 | function getOptionsFromElement(element){ |
||
| 5 | var options = {}; |
||
| 6 | for(var property in defaults){ |
||
| 7 | if(defaults.hasOwnProperty(property)){ |
||
| 8 | // jsbarcode-* |
||
| 9 | if(element.hasAttribute("jsbarcode-" + property.toLowerCase())){ |
||
| 10 | options[property] = element.getAttribute("jsbarcode-" + property.toLowerCase()); |
||
| 11 | } |
||
| 12 | |||
| 13 | // data-* |
||
| 14 | if(element.hasAttribute("data-" + property.toLowerCase())){ |
||
| 15 | options[property] = element.getAttribute("data-" + property.toLowerCase()); |
||
| 16 | } |
||
| 17 | } |
||
| 18 | } |
||
| 19 | |||
| 20 | options["value"] = element.getAttribute("jsbarcode-value") || element.getAttribute("data-value"); |
||
| 21 | |||
| 22 | // Since all atributes are string they need to be converted to integers |
||
| 23 | options = optionsFromStrings(options); |
||
| 24 | |||
| 25 | return options; |
||
| 26 | } |
||
| 27 | |||
| 29 |